import System


say_hello x =
    case x of
        [] -> "World"
        [x] -> x
        x -> foldr (\x y -> x ++ ", " ++ y) ("and " ++ last x) (init x)


main =
    do
        names <- getArgs
        putStr ("Hello, " ++ say_hello names ++ "!\n")


{-
say_hello :: [String] -> String

say_hello [] = "World"

say_hello [x] = x

say_hello [x, y] = x ++ ", and " ++ y

-- Using absolute positionals for pattern matching removes possibility of
--   using [x:xs]; ends up saying [] and Char don't type together
say_hello x =
    (head x) ++ ", " ++ (say_hello (tail x))
-}
